import Vue from 'vue'

export const dictFormat = function(key, val, def) {
  let dictData = Vue.ls.get('DICTDATA')
  console.log(dictData);
  let dict = dictData[key]
  Vue.prototype.$dictData = dictData
  if (dict) {
    let data = dict.filter(item => item.code == val)
    return data.length ? data[0].name : def
  } else {
    return 'key is null'
  }
}
export const columnFormatter = function(array, v) {
  let obj = array.filter(item => {
    return item.value == v
  })
  if (obj.length > 0) {
    return obj[0].label
  }
  return '-'
}

